package com.ysd.twocrm.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ysd.twocrm.entity.Roles;
import com.ysd.twocrm.mapper.RolesMapper;
import com.ysd.twocrm.service.RolesService;
import com.ysd.twocrm.utils.LayuiUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RolesServiceImpl implements RolesService {
    @Autowired
    private RolesMapper rolesMapper;
    @Override
    public LayuiUtils<Roles> LAYUI_ROLES(Integer page, Roles r) {
        QueryWrapper<Roles> queryWrapper=new QueryWrapper<Roles>();
        Page<Roles> rolesPage=new Page<Roles>(page,10);
        if(r.getRoleName()!=null){
            queryWrapper.like("roleName",r.getRoleName());
        }
        Page<Roles> rolesPage1 = rolesMapper.selectPage(rolesPage, queryWrapper);
        LayuiUtils<Roles> layuiUtils =new LayuiUtils<Roles>();
        layuiUtils.setData(rolesPage1.getRecords());
        layuiUtils.setCount(rolesPage1.getTotal());
        return layuiUtils;
    }
}
